/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewJFrame.java
 *
 * Created on Dec 18, 2009, 2:44:14 PM
 */
package oneStopShop.UserInterfaces;

import java.util.ArrayList;

import java.util.Date;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.UIManager;

import oneStopShop.Beans.Account;
import oneStopShop.Beans.Customer;
import oneStopShop.Beans.CustomerOrder;
import oneStopShop.Beans.Item;
import oneStopShop.Beans.LargeOrderCustomer;
import oneStopShop.Util.AccountTableModel;
import oneStopShop.Util.CustomerTableModel;
import oneStopShop.Util.TableModelOrderLog;
import oneStopShop.Util.TableModelTransactionItem;
import oneStopShop.Util.TableModelTransactionLog;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author Administrator
 */
public class MainForm extends javax.swing.JFrame {

    SessionFactory sessionFactory = null;
    ArrayList<String[]> transactionItems;
    ArrayList<String[]> transactionLogs;
    ArrayList<String[]> transactionLogItems;
    ArrayList<String[]> orderLogs;
    ArrayList<String[]> orderLogItems;

    /** Creates new form NewJFrame */
    public MainForm() {

        transactionItems = new ArrayList<String[]>();
        

        init();
        initComponents();

        setLocationRelativeTo(null);
        setVisible(true);

        sessionFactory = new Configuration().configure().buildSessionFactory();

        initialWork();
        setTransactionNumber();
        loadTransactionLog();
        loadOrderLog();
        transactionLogItemTableRefresh();
        orderLogItemTableRefresh();

        modifyCustomerWindow();         //author-dinesh
        modifyAccountWindow();          //author-dinesh
    }


     private void modifyAccountWindow() {                 //author-dinesh

        this.loadDataToAccountTable();
        this.accountPaymentAmmountLable.setEnabled(false);
        this.accountPaymentAmmount.setEnabled(false);
        this.accountAdd.setEnabled(false);
        this.accountRefresh.setEnabled(false);
    }

    private void loadDataToAccountTable() {                     //author-dinesh

        this.accountTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        Session session = null;
        try {
            session = sessionFactory.openSession();
            List<Account> temp = (List<Account>) session.createCriteria(Account.class).list();
            this.accountTable.setModel(new AccountTableModel(temp));

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }
    }

    private void modifyCustomerWindow() {//author-dinesh*****intiall setting of customer window goes under this method
        this.customerTypeChange();
        customerEdit.setEnabled(false);
        customerDelete.setEnabled(false);
        customerAdd.setEnabled(true);

        this.loadDataToTable();
    }

    private void refreshCustomerWindow() {//author-dinesh
        this.customerCustomerNumber.setEnabled(true);
        this.customerCustomerType.setEnabled(true);
        this.customerCustomerCreditLimit.setText(null);

        this.customerCustomerCreditBalance.setText(null);

        this.brn.setText(null);

        this.customerSalesRepID.setText(null);
        this.customerCustomerNumber.setText(null);
        this.customerCustomerName.setText(null);
        this.customerCustomerAddress.setText(null);
        this.customerContactNumber.setText(null);
        this.customerCustomerIDSearch.setText(null);
        this.modifyCustomerWindow();
    }

    public Customer getCustomer(int customerNumber) {//author-dinesh
        Session session = null;
        List<Customer> list = null;
        try {
            session = sessionFactory.openSession();
            list = (List<Customer>) session.createCriteria(Customer.class).add(Restrictions.eq("customerNumber", customerNumber)).list();
        } catch (Exception e) {
            System.out.println("Exception in retriving customer");
        } finally {
            session.close();
        }
        return list.get(0);

    }

    public LargeOrderCustomer getLargeOrderCustomer(int customerNumber) {//author-dinesh
        Session session = null;
        List<LargeOrderCustomer> list = null;
        try {
            session = sessionFactory.openSession();
            list = (List<LargeOrderCustomer>) session.createCriteria(LargeOrderCustomer.class).add(Restrictions.eq("customerNumber", customerNumber)).list();
        } catch (Exception e) {
            System.out.println("Exception in retriving large customer");
        } finally {
            session.close();
        }
        return list.get(0);

    }

    public Account getAccount(int customerNumber) {//author-dinesh
        Session session = null;
        List<Account> list = null;
        try {
            session = sessionFactory.openSession();
            list = (List<Account>) session.createCriteria(Account.class).add(Restrictions.eq("customerNumber", customerNumber)).list();
        } catch (Exception e) {
            System.out.println("Exception in retriving Account");
        } finally {
            session.close();
        }
        return list.get(0);

    }

    public Account getAccountByAccountID(int accID) {
        Session session = null;
        List<Account> list = null;
        try {
            session = sessionFactory.openSession();
            list = (List<Account>) session.createCriteria(Account.class).add(Restrictions.eq("accountId", accID)).list();
        } catch (Exception e) {
            System.out.println("Exception in retriving Account");
        } finally {
            session.close();
        }
        return list.get(0);
    }

    private void loadDataToTable() {//author-dinesh
        this.customerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        Session session = null;
        try {
            session = sessionFactory.openSession();
            List<Customer> temp = (List<Customer>) session.createCriteria(Customer.class).list();
            this.customerTable.setModel(new CustomerTableModel(temp));

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }
    }

    private int getCustomerType(String type) {//author-dinesh

        if (type.equals("Retail Normal")) {
            return 1;
        }
        if (type.equals("Retail VIP")) {
            return 2;
        }
        if (type.equals("Large Order")) {
            return 3;
        }
        if (type.equals("Mail Order")) {
            return 4;
        }

        return -1;
    }

    private String validateForm() {                                     //author-dinesh
        try {
            Integer.parseInt(this.customerCustomerNumber.getText());

        } catch (Exception e) {
            return "Customer Number should be an integer";

        }
        String s = this.customerCustomerName.getText();
        if (this.customerCustomerName.getText().trim().equals("")) {
            return "Customer Name should be inserted";
        }
        if (this.customerCustomerAddress.getText().trim().equals("")) {
            return "Customer Address should be inserted";
        }

        try {
            Integer.parseInt(this.customerContactNumber.getText());

        } catch (Exception e) {
            return "Contact Number should be an integer";

        }

        if (this.customerSalesRepID.isEnabled()) {
            try {
                Integer.parseInt(this.customerSalesRepID.getText());

            } catch (Exception e) {
                return "Sales Rep ID should be an integer";

            }
        }
        if (this.brn.isEnabled()) {
            try {
                Integer.parseInt(this.brn.getText());

            } catch (Exception e) {
                return "Business Registration Number should be an integer";

            }
        }
        if (this.customerCustomerCreditLimit.isEnabled()) {
            try {
                Float.parseFloat(this.customerCustomerCreditLimit.getText());

                if (Float.parseFloat(this.customerCustomerCreditLimit.getText()) < 0) {
                    return "Credit Limit should be a positive floting point number";
                }
            } catch (Exception e) {
                return "Credit Limit should be a floting point number";

            }
        }


        return null;
    }

    private void customerTypeChange() {  //author-dinesh

        String type = (String) customerCustomerType.getSelectedItem();

        if (type.equals("Retail Normal")) {
            this.customerAccountIDLable.setEnabled(false);
            this.customerCustomerAcountID.setEnabled(false);
            this.customerCreditLimitLable.setEnabled(false);
            this.customerCustomerCreditLimit.setEnabled(false);
            this.customerCreditBalanceLable.setEnabled(false);
            this.customerCustomerCreditBalance.setEnabled(false);
            this.customerBRN.setEnabled(false);
            this.brn.setEnabled(false);
            this.customerSalesRepIDLable.setEnabled(false);
            this.customerSalesRepID.setEnabled(false);
            this.customerCustomerAcountID.setText(null);
            this.customerCustomerCreditLimit.setText(null);
            this.brn.setText(null);
            this.customerSalesRepID.setText(null);
            this.customerCustomerCreditBalance.setText(null);



        } else if (type.equals("Retail VIP")) {
            this.customerAccountIDLable.setEnabled(true);
            this.customerCustomerAcountID.setEnabled(true);
            this.customerCreditLimitLable.setEnabled(true);
            this.customerCustomerCreditLimit.setEnabled(true);
            this.customerCreditBalanceLable.setEnabled(true);
            this.customerCustomerCreditBalance.setEnabled(true);
            this.customerBRN.setEnabled(false);
            this.brn.setEnabled(false);
            this.customerSalesRepIDLable.setEnabled(false);
            this.customerSalesRepID.setEnabled(false);
            this.customerCustomerAcountID.setText(Integer.toString(this.getNextAccountNo()));
            this.brn.setText(null);
            this.customerSalesRepID.setText(null);

        } else if (type.equals("Large Order")) {
            this.customerAccountIDLable.setEnabled(true);
            this.customerCustomerAcountID.setEnabled(true);
            this.customerCreditLimitLable.setEnabled(true);
            this.customerCustomerCreditLimit.setEnabled(true);
            this.customerCreditBalanceLable.setEnabled(true);
            this.customerCustomerCreditBalance.setEnabled(true);
            this.customerBRN.setEnabled(true);
            this.brn.setEnabled(true);
            this.customerSalesRepIDLable.setEnabled(true);
            this.customerSalesRepID.setEnabled(true);
            this.customerCustomerAcountID.setText(Integer.toString(this.getNextAccountNo()));

        } else {

            this.customerAccountIDLable.setEnabled(true);
            this.customerCustomerAcountID.setEnabled(true);
            this.customerCreditLimitLable.setEnabled(true);
            this.customerCustomerCreditLimit.setEnabled(true);
            this.customerCreditBalanceLable.setEnabled(true);
            this.customerCustomerCreditBalance.setEnabled(true);
            this.customerBRN.setEnabled(false);
            this.brn.setEnabled(false);
            this.customerSalesRepIDLable.setEnabled(false);
            this.customerSalesRepID.setEnabled(false);
            this.customerCustomerAcountID.setText(Integer.toString(this.getNextAccountNo()));
            this.brn.setText(null);
            this.customerSalesRepID.setText(null);

        }
    }

    private int getNextAccountNo() {//author-dinesh
        Session session = null;
        Integer nextAccountID = 1;

        try {
            session = sessionFactory.openSession();
            String SQL_QUERY = "select max(accountId)from Account";
            Query query = session.createQuery(SQL_QUERY);
            List<Integer> list = query.list();
            if (list != null) {

                Integer temp = list.get(0);
                if (temp != null) {
                    nextAccountID = list.get(0) + 1;
                }

            }

        } catch (Exception e) {
            System.out.println("Exception in clculating nxt accoiunt ID");
        } finally {
            session.close();
        }
        return nextAccountID;
    }

    private void addCustomer() {              //author-dinesh
        int ID = Integer.parseInt(this.customerCustomerNumber.getText());
        String name = this.customerCustomerName.getText();
        String address = this.customerCustomerAddress.getText();
        int contactNumber = Integer.parseInt(this.customerContactNumber.getText());
        int type = this.getCustomerType((String) this.customerCustomerType.getSelectedItem());

        float creditLimit = 0;
        int salesRepID = 0;
        int brn = 0;

        if (type == 2 || type == 3 || type == 4) {
            creditLimit = Float.parseFloat(this.customerCustomerCreditLimit.getText());
            if (type == 3) {
                salesRepID = Integer.parseInt(this.customerSalesRepID.getText());
                brn = Integer.parseInt(this.brn.getText());
            }

        }
        Customer customer = new Customer(ID, name, address, contactNumber, type);
        if (type == 1) {//adding retail normal customer

            Session session = null;
            try {
                session = sessionFactory.openSession();
                Transaction transaction = session.beginTransaction();
                session.save(customer);
                transaction.commit();
                JOptionPane.showMessageDialog(this, "customer added successfully!", "Succesfull", JOptionPane.INFORMATION_MESSAGE);

                System.out.println("customer added successfully");
                this.refreshCustomerWindow();
                this.loadDataToTable();

            } catch (Exception e) {
                JOptionPane.showMessageDialog(this, "Unable to add retail normal customer, a customer exist with this customer ID", "Error", JOptionPane.ERROR_MESSAGE);
                System.out.println(">>>>>>>>>>>>>>>>>>>>>exception in customerAddActionPerformed method");
            //e.printStackTrace();
            } finally {
                session.close();
            }

        } else {//adding retail VIP,Large order or Mail order customer
            Session session = null;

            try {
                int nxtAccountID = this.getNextAccountNo();
                Account account = new Account(nxtAccountID, ID, new Date(), creditLimit, creditLimit);

                session = sessionFactory.openSession();
                Transaction transaction = session.beginTransaction();
                session.save(customer);
                if (type == 3) {//if customer Large order customer
                    LargeOrderCustomer largeCustomer = new LargeOrderCustomer(ID, brn, salesRepID);
                    session.save(largeCustomer);
                }
                session.save(account);
                transaction.commit();

                if (type == 2) {
                    JOptionPane.showMessageDialog(this, "VIP customer added and account created successfully!", "Succesfull", JOptionPane.INFORMATION_MESSAGE);

                } else if (type == 3) {
                    JOptionPane.showMessageDialog(this, "Large Order customer added and account created successfully!", "Succesfull", JOptionPane.INFORMATION_MESSAGE);

                } else {
                    JOptionPane.showMessageDialog(this, "Mail Order customer added and account created successfully!", "Succesfull", JOptionPane.INFORMATION_MESSAGE);

                }

                System.out.println("customer added successfully");
                this.refreshCustomerWindow();
                this.modifyAccountWindow();
            //this.loadDataToTable();

            } catch (Exception e) {
                JOptionPane.showMessageDialog(this, "Unable to add  customer, a customer exist with this customer ID", "Error", JOptionPane.ERROR_MESSAGE);
                System.out.println(">>>>>>>>>>>>>>>>>>>>>exception in customerAddActionPerformed method");
            //e.printStackTrace();
            } finally {
                session.close();
            }


        }
    //double creditLimit = Double.parseDouble(customerCustomerCreditLimit.getText());




    }

    private void editCustomer() {                                //author-dinesh
        System.out.println("?????????editing");
        int ID = Integer.parseInt(this.customerCustomerNumber.getText());
        String name = this.customerCustomerName.getText();
        String address = this.customerCustomerAddress.getText();
        int contactNumber = Integer.parseInt(this.customerContactNumber.getText());
        int type = this.getCustomerType((String) this.customerCustomerType.getSelectedItem());

        int nxtAccountID = 0;

        float creditLimit = 0;
        int salesRepID = 0;
        int brn = 0;

        if (type == 2 || type == 3 || type == 4) {
            nxtAccountID = Integer.parseInt(this.customerCustomerAcountID.getText());

            creditLimit = Float.parseFloat(this.customerCustomerCreditLimit.getText());
            if (type == 3) {
                salesRepID = Integer.parseInt(this.customerSalesRepID.getText());
                brn = Integer.parseInt(this.brn.getText());
            }

        }
        Customer customer = new Customer(ID, name, address, contactNumber, type);

        if (type == 1) {//editing retail normal customer

            Session session = null;
            try {
                session = sessionFactory.openSession();
                Transaction transaction = session.beginTransaction();
                session.update(customer);
                transaction.commit();
                JOptionPane.showMessageDialog(this, "customer updated successfully!", "Succesfull", JOptionPane.INFORMATION_MESSAGE);

                System.out.println("customer updated successfully");
                this.refreshCustomerWindow();
            //this.loadDataToTable();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(this, "Unable to edit retail normal customer, a customer exist with this customer ID", "Error", JOptionPane.ERROR_MESSAGE);
                System.out.println(">>>>>>>>>>>>>>>>>>>>>exception in customerAddActionPerformed method");
            //e.printStackTrace();
            } finally {
                session.close();
            }

        } else {//adding retail VIP,Large order or Mail order customer
            Session session = null;

            try {
                Account oldAccount = this.getAccount(ID);
                float usedCreditAmmount = oldAccount.getCreditLimit() - oldAccount.getCreditBalance();
                if (creditLimit >= usedCreditAmmount) {

                    Account editedAccount = new Account(nxtAccountID, ID, new Date(), creditLimit, (creditLimit - usedCreditAmmount));

                    session = sessionFactory.openSession();
                    Transaction transaction = session.beginTransaction();
                    session.update(customer);
                    if (type == 3) {//if customer Large order customer
                        LargeOrderCustomer largeCustomer = new LargeOrderCustomer(ID, brn, salesRepID);
                        session.update(largeCustomer);
                    }
                    session.update(editedAccount);
                    transaction.commit();

                    if (type == 2) {
                        JOptionPane.showMessageDialog(this, "VIP customer edited successfully!", "Succesfull", JOptionPane.INFORMATION_MESSAGE);

                    } else if (type == 3) {
                        JOptionPane.showMessageDialog(this, "Large Order customer edited successfully!", "Succesfull", JOptionPane.INFORMATION_MESSAGE);

                    } else {
                        JOptionPane.showMessageDialog(this, "Mail Order customer edited successfully!", "Succesfull", JOptionPane.INFORMATION_MESSAGE);

                    }

                    System.out.println("customer added successfully");
                    this.refreshCustomerWindow();
                    this.modifyAccountWindow();
                } else {
                    JOptionPane.showMessageDialog(this, "Invalid credit limit!", "Error", JOptionPane.ERROR_MESSAGE);

                }

            //this.loadDataToTable();

            } catch (Exception e) {
                JOptionPane.showMessageDialog(this, "Unable to edit  customer", "Error", JOptionPane.ERROR_MESSAGE);
                System.out.println(">>>>>>>>>>>>>>>>>>>>>exception in customerAddActionPerformed method");
            //e.printStackTrace();
            } finally {
                session.close();
            }
        }
    }

    private void refreshAccountWindow() {
        //author-dinesh
        this.accountPaymentAmmount.setText(null);
        this.accountSearchID.setText(null);
        this.modifyAccountWindow();
    //this.loadDataToAccountTable();
    }




    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    void init() {

//        JFrame.setDefaultLookAndFeelDecorated(true);
//        JDialog.setDefaultLookAndFeelDecorated(true);
//        LiquidLookAndFeel.setShowTableGrids(true);
//        try {
//            UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel"); // apply the look and feel to whole system
//        } catch (Exception e) {
//        }

        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    void setTransactionNumber() {
        try {

            Session session = sessionFactory.openSession();
            Transaction transaction = session.beginTransaction();

            //String SQL_QUERY = "select max(trn) from transaction transaction";
            String SQL_QUERY = "select max(trn) from Transaction transaction";

            Query query = session.createQuery(SQL_QUERY);
            //Object df = query.uniqueResult();
            Integer transact = (Integer) query.uniqueResult();


            int maxTRN = 0;

            if (!(transact == null)) {
                maxTRN = transact + 1;

            } else {
                maxTRN = 1;
            }

            this.transactionNumber.setText(Integer.toString(maxTRN));


            // List<oneStopShop.Beans.Transaction> allTransactions = (List<oneStopShop.Beans.Transaction>) session.createCriteria(oneStopShop.Beans.Transaction.class).list();
            //oneStopShop.Beans.Transaction transact = (oneStopShop.Beans.Transaction) session.createCriteria(oneStopShop.Beans.Transaction.class).add(Restrictions.eq("trn", 1000)).uniqueResult();

            transaction.commit();
            session.flush();
            session.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    void transactionLogItemTableRefresh(){
        transactionLogItems = new ArrayList<String[]>();
       this.transactionLogsItems.setModel(new TableModelTransactionItem(transactionLogItems));

        
    }

    void loadTransactionLog() {

        transactionLogs = new ArrayList<String[]>();
        try {

            Session session = sessionFactory.openSession();
            Transaction transaction = session.beginTransaction();

            List<oneStopShop.Beans.Transaction> transactionLogList = (List<oneStopShop.Beans.Transaction>) session.createCriteria(oneStopShop.Beans.Transaction.class).list();

            // Item currentUpdatingItem = (Item) session.createCriteria(Item.class).add(Restrictions.eq("itemNumber", Integer.parseInt(transactionItems.get(k)[0]))).uniqueResult();
            for (int i = 0; i < transactionLogList.size(); i++) {

                oneStopShop.Beans.Transaction currentTransactionLog = transactionLogList.get(i);

                String transactionTypeString;

                if (currentTransactionLog.getTransactionType() == 1) {

                    transactionTypeString = "Normal";

                } else {
                    transactionTypeString = "Ordered";
                }

                String[] transacLogRow = {Integer.toString(currentTransactionLog.getTrn()), Integer.toString(currentTransactionLog.getCustomerNumber()), currentTransactionLog.getDate().toString(), transactionTypeString, Float.toString(currentTransactionLog.getAmount())};


                transactionLogs.add(transacLogRow);
            }

            //session.save(addingTransactionItems);
            transaction.commit();
            session.flush();
            session.close();




        } catch (Exception e) {
            e.printStackTrace();
        }

        this.transactionLogTable.setModel(new TableModelTransactionLog(transactionLogs));

    }


        void loadOrderLog() {

        orderLogs = new ArrayList<String[]>();
        try {

            Session session = sessionFactory.openSession();
            Transaction transaction = session.beginTransaction();

            List<CustomerOrder> orderLogList = (List<CustomerOrder>) session.createCriteria(CustomerOrder.class).list();

            // Item currentUpdatingItem = (Item) session.createCriteria(Item.class).add(Restrictions.eq("itemNumber", Integer.parseInt(transactionItems.get(k)[0]))).uniqueResult();
            for (int i = 0; i < orderLogList.size(); i++) {

                CustomerOrder currentOrderLog = orderLogList.get(i);


                String[] transacLogRow = {Integer.toString(currentOrderLog.getOrderNumber()),currentOrderLog.getOrderDate().toString(), Float.toString(currentOrderLog.getOrderCost()), Integer.toString(currentOrderLog.getCustomerNumber()), Float.toString(currentOrderLog.getAdvanceAmount())};


                orderLogs.add(transacLogRow);
            }

            //session.save(addingTransactionItems);
            transaction.commit();
            session.flush();
            session.close();




        } catch (Exception e) {
            e.printStackTrace();
        }

        this.orderLogTable.setModel(new TableModelOrderLog(orderLogs));

    }



    void initialWork() {


        this.transactionDateTime.setText((new Date()).toString());

        this.transactionOrderNumber.setEnabled(false);
        this.jLabel8.setEnabled(false);
        this.transactionOrderAdvanceAmount.setEnabled(false);
        this.jLabel39.setEnabled(false);
        this.transactionOrderOk.setEnabled(false);
        this.jLabel38.setEnabled(false);

        this.jLabel42.setEnabled(false);
        this.jLabel40.setEnabled(false);
        this.transactionCreditBalance.setEnabled(false);

    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        accountPanel2 = new javax.swing.JTabbedPane();
        transactionPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        transactionCustomerNumber = new javax.swing.JTextField();
        transactionAdd = new javax.swing.JButton();
        transactionNormal = new javax.swing.JRadioButton();
        transactionOrdered = new javax.swing.JRadioButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        transactionItemTable = new javax.swing.JTable();
        item = new javax.swing.JLabel();
        transactionItemNumber = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        transactionQuantity = new javax.swing.JTextField();
        transactionItemOk = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        transactionOrderOk = new javax.swing.JButton();
        transactionOrderNumber = new javax.swing.JTextField();
        transactionItemDelete = new javax.swing.JButton();
        transactionCreditBalance = new javax.swing.JLabel();
        transactionNumber = new javax.swing.JLabel();
        transactionOrderAdvanceAmount = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        transactionDateTime = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        transactionCash = new javax.swing.JRadioButton();
        transactionCredit = new javax.swing.JRadioButton();
        jLabel42 = new javax.swing.JLabel();
        transactionTotalCost = new javax.swing.JLabel();
        jLabel43 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        customerPanel = new javax.swing.JPanel();
        customerCutomerNumberLable = new javax.swing.JLabel();
        customerNameLable = new javax.swing.JLabel();
        customerAdd = new javax.swing.JButton();
        customerEdit = new javax.swing.JButton();
        customerDelete = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        customerTable = new javax.swing.JTable();
        customerAddressLable = new javax.swing.JLabel();
        customerContactNumberLable = new javax.swing.JLabel();
        customerCustomerTypeLable = new javax.swing.JLabel();
        customerCustomerNumber = new javax.swing.JTextField();
        customerCustomerName = new javax.swing.JTextField();
        customerCustomerAddress = new javax.swing.JTextField();
        customerContactNumber = new javax.swing.JTextField();
        customerCustomerType = new javax.swing.JComboBox();
        customerSalesRepIDLable = new javax.swing.JLabel();
        customerSalesRepID = new javax.swing.JTextField();
        customerBRN = new javax.swing.JLabel();
        brn = new javax.swing.JTextField();
        customerCreditLimitLable = new javax.swing.JLabel();
        customerAccountIDLable = new javax.swing.JLabel();
        customerCustomerCreditLimit = new javax.swing.JTextField();
        customerCustomerIDSearchLable = new javax.swing.JLabel();
        customerCustomerIDSearch = new javax.swing.JTextField();
        customerSearch = new javax.swing.JButton();
        customerCreditBalanceLable = new javax.swing.JLabel();
        customerCustomerCreditBalance = new javax.swing.JLabel();
        customerCustomerAcountID = new javax.swing.JLabel();
        customerRefresh = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        accountPanel = new javax.swing.JPanel();
        accountAccountIDLable = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        accountTable = new javax.swing.JTable();
        accountAdd = new javax.swing.JButton();
        accountPaymentAmmount = new javax.swing.JTextField();
        accountPaymentAmmountLable = new javax.swing.JLabel();
        accountSearchID = new javax.swing.JTextField();
        jButton18 = new javax.swing.JButton();
        accountRefresh = new javax.swing.JButton();
        orderPanel = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        item1 = new javax.swing.JLabel();
        jTextField10 = new javax.swing.JTextField();
        jTextField11 = new javax.swing.JTextField();
        jTextField12 = new javax.swing.JTextField();
        jTextField13 = new javax.swing.JTextField();
        jTextField14 = new javax.swing.JTextField();
        item2 = new javax.swing.JLabel();
        jTextField15 = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jButton5 = new javax.swing.JButton();
        jTextField16 = new javax.swing.JTextField();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jTextField22 = new javax.swing.JTextField();
        jTextField23 = new javax.swing.JTextField();
        jTextField24 = new javax.swing.JTextField();
        jTextField25 = new javax.swing.JTextField();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTable4 = new javax.swing.JTable();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        list1 = new java.awt.List();
        list2 = new java.awt.List();
        jButton14 = new javax.swing.JButton();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTable5 = new javax.swing.JTable();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jButton17 = new javax.swing.JButton();
        jTextField26 = new javax.swing.JTextField();
        jTextField27 = new javax.swing.JTextField();
        jTextField28 = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        transactionLogsItems = new javax.swing.JTable();
        jScrollPane9 = new javax.swing.JScrollPane();
        transactionLogTable = new javax.swing.JTable();
        jLabel44 = new javax.swing.JLabel();
        transactionLogCustomerNumber = new javax.swing.JTextField();
        transactionLogSearch = new javax.swing.JButton();
        transactionLogRefresh = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        orderLogsItems = new javax.swing.JTable();
        jScrollPane10 = new javax.swing.JScrollPane();
        orderLogTable = new javax.swing.JTable();
        jLabel45 = new javax.swing.JLabel();
        orderLogCustomerNumber = new javax.swing.JTextField();
        orderLogSearch = new javax.swing.JButton();
        orderLogRefresh = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        transactionPanel.setLayout(null);

        jLabel1.setText("Transaction Registration Number");
        transactionPanel.add(jLabel1);
        jLabel1.setBounds(30, 30, 190, 20);

        jLabel2.setText("Customer Number");
        transactionPanel.add(jLabel2);
        jLabel2.setBounds(30, 60, 120, 20);

        jLabel3.setText("Date /Time");
        transactionPanel.add(jLabel3);
        jLabel3.setBounds(30, 90, 100, 20);

        jLabel4.setText("Transaction Type");
        transactionPanel.add(jLabel4);
        jLabel4.setBounds(30, 130, 130, 20);

        jLabel5.setText("Total Cost");
        transactionPanel.add(jLabel5);
        jLabel5.setBounds(30, 400, 70, 14);
        transactionPanel.add(transactionCustomerNumber);
        transactionCustomerNumber.setBounds(240, 60, 190, 20);

        transactionAdd.setText("Add");
        transactionAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transactionAddActionPerformed(evt);
            }
        });
        transactionPanel.add(transactionAdd);
        transactionAdd.setBounds(540, 440, 70, 50);

        buttonGroup1.add(transactionNormal);
        transactionNormal.setSelected(true);
        transactionNormal.setText("Normal");
        transactionNormal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transactionNormalActionPerformed(evt);
            }
        });
        transactionPanel.add(transactionNormal);
        transactionNormal.setBounds(240, 130, 90, 23);

        buttonGroup1.add(transactionOrdered);
        transactionOrdered.setText("Ordered");
        transactionOrdered.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transactionOrderedActionPerformed(evt);
            }
        });
        transactionPanel.add(transactionOrdered);
        transactionOrdered.setBounds(360, 130, 110, 23);

        transactionItemTable.setModel(new TableModelTransactionItem(transactionItems));
        transactionItemTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(transactionItemTable);

        transactionPanel.add(jScrollPane1);
        jScrollPane1.setBounds(20, 270, 630, 100);

        item.setText("Item Number");
        transactionPanel.add(item);
        item.setBounds(30, 170, 90, 14);
        transactionPanel.add(transactionItemNumber);
        transactionItemNumber.setBounds(140, 170, 90, 20);

        jLabel7.setText("Quantity");
        transactionPanel.add(jLabel7);
        jLabel7.setBounds(260, 170, 70, 14);

        transactionQuantity.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transactionQuantityActionPerformed(evt);
            }
        });
        transactionPanel.add(transactionQuantity);
        transactionQuantity.setBounds(340, 170, 90, 20);

        transactionItemOk.setText("Ok");
        transactionItemOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transactionItemOkActionPerformed(evt);
            }
        });
        transactionPanel.add(transactionItemOk);
        transactionItemOk.setBounds(450, 170, 80, 23);

        jLabel8.setText("Order Number");
        transactionPanel.add(jLabel8);
        jLabel8.setBounds(30, 220, 100, 14);

        transactionOrderOk.setText("Ok");
        transactionOrderOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transactionOrderOkActionPerformed(evt);
            }
        });
        transactionPanel.add(transactionOrderOk);
        transactionOrderOk.setBounds(530, 220, 80, 23);
        transactionPanel.add(transactionOrderNumber);
        transactionOrderNumber.setBounds(140, 220, 90, 20);

        transactionItemDelete.setText("Delete");
        transactionItemDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transactionItemDeleteActionPerformed(evt);
            }
        });
        transactionPanel.add(transactionItemDelete);
        transactionItemDelete.setBounds(540, 170, 90, 23);

        transactionCreditBalance.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        transactionPanel.add(transactionCreditBalance);
        transactionCreditBalance.setBounds(170, 480, 160, 20);

        transactionNumber.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        transactionPanel.add(transactionNumber);
        transactionNumber.setBounds(240, 30, 190, 20);

        transactionOrderAdvanceAmount.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        transactionPanel.add(transactionOrderAdvanceAmount);
        transactionOrderAdvanceAmount.setBounds(410, 220, 90, 20);

        jLabel38.setText("Rs.");
        transactionPanel.add(jLabel38);
        jLabel38.setBounds(370, 220, 30, 14);

        jLabel39.setText("Advance amount");
        transactionPanel.add(jLabel39);
        jLabel39.setBounds(260, 220, 110, 14);

        transactionDateTime.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        transactionPanel.add(transactionDateTime);
        transactionDateTime.setBounds(240, 90, 190, 20);

        jLabel40.setText("Rs.");
        transactionPanel.add(jLabel40);
        jLabel40.setBounds(130, 480, 30, 14);

        jLabel41.setText("Payment Type");
        transactionPanel.add(jLabel41);
        jLabel41.setBounds(30, 440, 90, 20);

        buttonGroup2.add(transactionCash);
        transactionCash.setSelected(true);
        transactionCash.setText("Cash");
        transactionCash.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transactionCashActionPerformed(evt);
            }
        });
        transactionPanel.add(transactionCash);
        transactionCash.setBounds(170, 440, 49, 23);

        buttonGroup2.add(transactionCredit);
        transactionCredit.setText("Credit");
        transactionCredit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transactionCreditActionPerformed(evt);
            }
        });
        transactionPanel.add(transactionCredit);
        transactionCredit.setBounds(260, 440, 93, 23);

        jLabel42.setText("Credit Balance");
        transactionPanel.add(jLabel42);
        jLabel42.setBounds(30, 480, 90, 14);

        transactionTotalCost.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        transactionPanel.add(transactionTotalCost);
        transactionTotalCost.setBounds(170, 400, 160, 20);

        jLabel43.setText("Rs.");
        transactionPanel.add(jLabel43);
        jLabel43.setBounds(130, 400, 30, 14);

        jButton1.setText("Refresh");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        transactionPanel.add(jButton1);
        jButton1.setBounds(540, 40, 71, 50);

        accountPanel2.addTab("Transaction", transactionPanel);

        customerPanel.setLayout(null);

        customerCutomerNumberLable.setText("Customer Number");
        customerPanel.add(customerCutomerNumberLable);
        customerCutomerNumberLable.setBounds(20, 10, 100, 14);

        customerNameLable.setText("Name");
        customerPanel.add(customerNameLable);
        customerNameLable.setBounds(20, 40, 27, 14);

        customerAdd.setText("Add");
        customerAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                customerAddActionPerformed(evt);
            }
        });
        customerPanel.add(customerAdd);
        customerAdd.setBounds(40, 290, 60, 23);

        customerEdit.setText("Edit");
        customerEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                customerEditActionPerformed(evt);
            }
        });
        customerPanel.add(customerEdit);
        customerEdit.setBounds(130, 290, 70, 23);

        customerDelete.setText("Delete");
        customerDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                customerDeleteActionPerformed(evt);
            }
        });
        customerPanel.add(customerDelete);
        customerDelete.setBounds(220, 290, 80, 23);

        customerTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        customerTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                customerTableMouseClicked(evt);
            }
        });
        customerTable.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                customerTableComponentShown(evt);
            }
        });
        jScrollPane2.setViewportView(customerTable);

        customerPanel.add(jScrollPane2);
        jScrollPane2.setBounds(30, 340, 610, 110);

        customerAddressLable.setText("Address");
        customerPanel.add(customerAddressLable);
        customerAddressLable.setBounds(20, 70, 39, 14);

        customerContactNumberLable.setText("Contact Number");
        customerPanel.add(customerContactNumberLable);
        customerContactNumberLable.setBounds(20, 100, 90, 14);

        customerCustomerTypeLable.setText("Customer Type");
        customerPanel.add(customerCustomerTypeLable);
        customerCustomerTypeLable.setBounds(20, 130, 80, 14);

        customerCustomerNumber.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                customerCustomerNumberActionPerformed(evt);
            }
        });
        customerPanel.add(customerCustomerNumber);
        customerCustomerNumber.setBounds(170, 10, 400, 20);
        customerPanel.add(customerCustomerName);
        customerCustomerName.setBounds(170, 40, 400, 20);
        customerPanel.add(customerCustomerAddress);
        customerCustomerAddress.setBounds(170, 70, 400, 20);
        customerPanel.add(customerContactNumber);
        customerContactNumber.setBounds(170, 100, 400, 20);

        customerCustomerType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Retail Normal", "Retail VIP", "Large Order", "Mail Order" }));
        customerCustomerType.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                customerCustomerTypeActionPerformed(evt);
            }
        });
        customerPanel.add(customerCustomerType);
        customerCustomerType.setBounds(170, 130, 400, 20);

        customerSalesRepIDLable.setText("Sales Rep Id");
        customerPanel.add(customerSalesRepIDLable);
        customerSalesRepIDLable.setBounds(20, 160, 80, 14);
        customerPanel.add(customerSalesRepID);
        customerSalesRepID.setBounds(170, 160, 400, 20);

        customerBRN.setText("Business Registration Number");
        customerPanel.add(customerBRN);
        customerBRN.setBounds(20, 190, 150, 14);
        customerPanel.add(brn);
        brn.setBounds(170, 190, 400, 20);

        customerCreditLimitLable.setText("Credit Limit");
        customerPanel.add(customerCreditLimitLable);
        customerCreditLimitLable.setBounds(230, 230, 80, 20);

        customerAccountIDLable.setText("Account ID");
        customerPanel.add(customerAccountIDLable);
        customerAccountIDLable.setBounds(20, 230, 70, 20);

        customerCustomerCreditLimit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                customerCustomerCreditLimitActionPerformed(evt);
            }
        });
        customerPanel.add(customerCustomerCreditLimit);
        customerCustomerCreditLimit.setBounds(320, 230, 100, 20);

        customerCustomerIDSearchLable.setText("Customer Number");
        customerPanel.add(customerCustomerIDSearchLable);
        customerCustomerIDSearchLable.setBounds(30, 470, 100, 20);
        customerPanel.add(customerCustomerIDSearch);
        customerCustomerIDSearch.setBounds(160, 470, 110, 20);

        customerSearch.setText("Search");
        customerSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                customerSearchActionPerformed(evt);
            }
        });
        customerPanel.add(customerSearch);
        customerSearch.setBounds(300, 470, 65, 23);

        customerCreditBalanceLable.setText("Credit Balance");
        customerPanel.add(customerCreditBalanceLable);
        customerCreditBalanceLable.setBounds(450, 230, 100, 20);

        customerCustomerCreditBalance.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        customerPanel.add(customerCustomerCreditBalance);
        customerCustomerCreditBalance.setBounds(540, 230, 90, 20);

        customerCustomerAcountID.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        customerPanel.add(customerCustomerAcountID);
        customerCustomerAcountID.setBounds(100, 230, 90, 20);

        customerRefresh.setText("Refresh");
        customerRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                customerRefreshActionPerformed(evt);
            }
        });
        customerPanel.add(customerRefresh);
        customerRefresh.setBounds(320, 290, 71, 23);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 670, Short.MAX_VALUE)
            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(customerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 670, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 513, Short.MAX_VALUE)
            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(customerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );

        accountPanel2.addTab("Customer", jPanel5);

        accountPanel.setLayout(null);

        accountAccountIDLable.setText("Account ID");
        accountPanel.add(accountAccountIDLable);
        accountAccountIDLable.setBounds(30, 430, 70, 20);

        accountTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        accountTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                accountTableMouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(accountTable);

        accountPanel.add(jScrollPane4);
        jScrollPane4.setBounds(20, 120, 630, 250);

        accountAdd.setText("Add");
        accountAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                accountAddActionPerformed(evt);
            }
        });
        accountPanel.add(accountAdd);
        accountAdd.setBounds(270, 50, 80, 23);
        accountPanel.add(accountPaymentAmmount);
        accountPaymentAmmount.setBounds(140, 50, 100, 20);

        accountPaymentAmmountLable.setText("Payment Amount");
        accountPanel.add(accountPaymentAmmountLable);
        accountPaymentAmmountLable.setBounds(30, 50, 100, 14);
        accountPanel.add(accountSearchID);
        accountSearchID.setBounds(100, 430, 100, 20);

        jButton18.setText("Search");
        jButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton18ActionPerformed(evt);
            }
        });
        accountPanel.add(jButton18);
        jButton18.setBounds(220, 430, 65, 23);

        accountRefresh.setText("Refresh");
        accountRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                accountRefreshActionPerformed(evt);
            }
        });
        accountPanel.add(accountRefresh);
        accountRefresh.setBounds(370, 50, 71, 23);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 670, Short.MAX_VALUE)
            .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(accountPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 670, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 513, Short.MAX_VALUE)
            .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(accountPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );

        accountPanel2.addTab("Account", jPanel6);

        orderPanel.setLayout(null);

        jLabel15.setText("Order Number ");
        orderPanel.add(jLabel15);
        jLabel15.setBounds(40, 50, 90, 14);

        jLabel16.setText("Order Date");
        orderPanel.add(jLabel16);
        jLabel16.setBounds(40, 80, 80, 14);

        jLabel17.setText("Customer Number");
        orderPanel.add(jLabel17);
        jLabel17.setBounds(40, 110, 90, 14);

        jLabel18.setText("Advance Amount");
        orderPanel.add(jLabel18);
        jLabel18.setBounds(40, 140, 160, 14);

        jLabel19.setText("Order Cost");
        orderPanel.add(jLabel19);
        jLabel19.setBounds(50, 450, 90, 14);

        item1.setText("Quantity");
        orderPanel.add(item1);
        item1.setBounds(230, 170, 70, 14);

        jTextField10.setText("jTextField10");
        orderPanel.add(jTextField10);
        jTextField10.setBounds(140, 140, 65, 20);
        orderPanel.add(jTextField11);
        jTextField11.setBounds(140, 50, 80, 20);
        orderPanel.add(jTextField12);
        jTextField12.setBounds(140, 80, 110, 20);
        orderPanel.add(jTextField13);
        jTextField13.setBounds(140, 110, 90, 20);

        jTextField14.setText("jTextField14");
        orderPanel.add(jTextField14);
        jTextField14.setBounds(290, 170, 65, 20);

        item2.setText("Item Number");
        orderPanel.add(item2);
        item2.setBounds(40, 170, 70, 14);

        jTextField15.setText("jTextField14");
        orderPanel.add(jTextField15);
        jTextField15.setBounds(180, 440, 140, 20);

        jButton3.setText("Cancel");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        orderPanel.add(jButton3);
        jButton3.setBounds(530, 440, 90, 23);

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane3.setViewportView(jTable2);

        orderPanel.add(jScrollPane3);
        jScrollPane3.setBounds(40, 210, 570, 120);

        jButton5.setText("OK");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        orderPanel.add(jButton5);
        jButton5.setBounds(390, 170, 50, 23);

        jTextField16.setText("jTextField14");
        orderPanel.add(jTextField16);
        jTextField16.setBounds(140, 170, 65, 20);

        jButton6.setText("Delete");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        orderPanel.add(jButton6);
        jButton6.setBounds(410, 350, 90, 23);

        jButton7.setText("OK");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        orderPanel.add(jButton7);
        jButton7.setBounds(420, 440, 90, 23);

        accountPanel2.addTab("Order", orderPanel);

        jPanel1.setLayout(null);

        jLabel25.setText("Avalable Quantity");
        jPanel1.add(jLabel25);
        jLabel25.setBounds(40, 120, 100, 14);

        jLabel26.setText("Item Number");
        jPanel1.add(jLabel26);
        jLabel26.setBounds(40, 30, 70, 14);

        jLabel27.setText("Item Name");
        jPanel1.add(jLabel27);
        jLabel27.setBounds(40, 60, 70, 14);

        jLabel28.setText("Item Price");
        jPanel1.add(jLabel28);
        jLabel28.setBounds(40, 90, 70, 14);

        jLabel29.setText("Item Price");
        jPanel1.add(jLabel29);
        jLabel29.setBounds(40, 90, 70, 14);

        jTextField22.setText("jTextField22");
        jPanel1.add(jTextField22);
        jTextField22.setBounds(140, 120, 65, 20);

        jTextField23.setText("jTextField22");
        jPanel1.add(jTextField23);
        jTextField23.setBounds(140, 30, 65, 20);

        jTextField24.setText("jTextField22");
        jPanel1.add(jTextField24);
        jTextField24.setBounds(140, 60, 65, 20);

        jTextField25.setText("jTextField22");
        jPanel1.add(jTextField25);
        jTextField25.setBounds(140, 90, 65, 20);

        jTable4.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane5.setViewportView(jTable4);

        jPanel1.add(jScrollPane5);
        jScrollPane5.setBounds(50, 270, 590, 110);

        jButton11.setText("Add");
        jPanel1.add(jButton11);
        jButton11.setBounds(60, 230, 70, 23);

        jButton12.setText("Edit");
        jPanel1.add(jButton12);
        jButton12.setBounds(161, 230, 70, 23);

        jButton13.setText("Delete");
        jPanel1.add(jButton13);
        jButton13.setBounds(250, 230, 70, 23);

        accountPanel2.addTab("Item", jPanel1);

        jPanel2.setLayout(null);

        jLabel30.setText("Customer IDs");
        jPanel2.add(jLabel30);
        jLabel30.setBounds(40, 120, 80, 14);

        jLabel31.setText("Sales Rep ID");
        jPanel2.add(jLabel31);
        jLabel31.setBounds(40, 30, 80, 14);

        jLabel32.setText("Name");
        jPanel2.add(jLabel32);
        jLabel32.setBounds(40, 60, 80, 14);

        jLabel33.setText("Contact Number");
        jPanel2.add(jLabel33);
        jLabel33.setBounds(40, 90, 80, 14);

        list1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                list1ActionPerformed(evt);
            }
        });
        jPanel2.add(list1);
        list1.setBounds(140, 120, 110, 110);
        jPanel2.add(list2);
        list2.setBounds(390, 120, 120, 110);

        jButton14.setText(">");
        jPanel2.add(jButton14);
        jButton14.setBounds(280, 160, 60, 23);

        jTable5.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane6.setViewportView(jTable5);

        jPanel2.add(jScrollPane6);
        jScrollPane6.setBounds(30, 340, 630, 120);

        jButton15.setText("Add");
        jPanel2.add(jButton15);
        jButton15.setBounds(60, 290, 70, 23);

        jButton16.setText("Edit");
        jPanel2.add(jButton16);
        jButton16.setBounds(160, 290, 70, 23);

        jButton17.setText("Delete");
        jPanel2.add(jButton17);
        jButton17.setBounds(250, 290, 70, 23);

        jTextField26.setText("jTextField26");
        jPanel2.add(jTextField26);
        jTextField26.setBounds(140, 30, 65, 20);

        jTextField27.setText("jTextField27");
        jPanel2.add(jTextField27);
        jTextField27.setBounds(140, 60, 65, 20);

        jTextField28.setText("jTextField28");
        jPanel2.add(jTextField28);
        jTextField28.setBounds(140, 90, 65, 20);

        accountPanel2.addTab("Sales Representative", jPanel2);

        jPanel3.setLayout(null);

        transactionLogsItems.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        transactionLogsItems.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane7.setViewportView(transactionLogsItems);

        jPanel3.add(jScrollPane7);
        jScrollPane7.setBounds(20, 340, 630, 150);

        transactionLogTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        transactionLogTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        transactionLogTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                transactionLogTableMouseClicked(evt);
            }
        });
        jScrollPane9.setViewportView(transactionLogTable);

        jPanel3.add(jScrollPane9);
        jScrollPane9.setBounds(20, 30, 630, 170);

        jLabel44.setText("Customer Number");
        jPanel3.add(jLabel44);
        jLabel44.setBounds(40, 270, 90, 20);
        jPanel3.add(transactionLogCustomerNumber);
        transactionLogCustomerNumber.setBounds(150, 270, 110, 20);

        transactionLogSearch.setText("Search");
        transactionLogSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transactionLogSearchActionPerformed(evt);
            }
        });
        jPanel3.add(transactionLogSearch);
        transactionLogSearch.setBounds(270, 270, 73, 23);

        transactionLogRefresh.setText("Refresh");
        transactionLogRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transactionLogRefreshActionPerformed(evt);
            }
        });
        jPanel3.add(transactionLogRefresh);
        transactionLogRefresh.setBounds(540, 210, 90, 30);

        accountPanel2.addTab("Transaction log", jPanel3);

        jPanel4.setLayout(null);

        orderLogsItems.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        orderLogsItems.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane8.setViewportView(orderLogsItems);

        jPanel4.add(jScrollPane8);
        jScrollPane8.setBounds(20, 310, 630, 170);

        orderLogTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        orderLogTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        orderLogTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                orderLogTableMouseClicked(evt);
            }
        });
        jScrollPane10.setViewportView(orderLogTable);

        jPanel4.add(jScrollPane10);
        jScrollPane10.setBounds(20, 30, 630, 160);

        jLabel45.setText("Customer Number");
        jPanel4.add(jLabel45);
        jLabel45.setBounds(30, 250, 90, 20);
        jPanel4.add(orderLogCustomerNumber);
        orderLogCustomerNumber.setBounds(140, 250, 110, 20);

        orderLogSearch.setText("Search");
        orderLogSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                orderLogSearchActionPerformed(evt);
            }
        });
        jPanel4.add(orderLogSearch);
        orderLogSearch.setBounds(270, 250, 73, 23);

        orderLogRefresh.setText("Refresh");
        orderLogRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                orderLogRefreshActionPerformed(evt);
            }
        });
        jPanel4.add(orderLogRefresh);
        orderLogRefresh.setBounds(540, 200, 90, 30);

        accountPanel2.addTab("Order log", jPanel4);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(accountPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 675, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(accountPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void transactionAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transactionAddActionPerformed

        addTransaction();
        addTransactionItems();
        updateAvailableQuantity();
        loadTransactionLog();
        loadOrderLog();

        if (transactionCredit.isSelected()) {
            updateCreditBalance();
        }

        if (transactionOrdered.isSelected()) {
            deleteTransactedOrder();
        }

        this.jButton1ActionPerformed(evt);
        
    // TODO add your handling code here:
}//GEN-LAST:event_transactionAddActionPerformed

    void addTransaction() {
        int transacNum = Integer.parseInt(this.transactionNumber.getText());
        int customerNum = Integer.parseInt(this.transactionCustomerNumber.getText());
        Date date = new Date();
        int transacType;

        if (this.transactionNormal.isSelected()) {
            transacType = 1;
        } else {
            transacType = 2;
        }

        float trasacTotalAmount = Float.parseFloat(this.transactionTotalCost.getText());

        try {

            Session session = sessionFactory.openSession();
            Transaction transaction = session.beginTransaction();


            oneStopShop.Beans.Transaction addingTransaction = new oneStopShop.Beans.Transaction();
            addingTransaction.setTrn(transacNum);
            addingTransaction.setCustomerNumber(customerNum);
            addingTransaction.setDate(date);
            addingTransaction.setTransactionType(transacType);
            addingTransaction.setAmount(trasacTotalAmount);
            session.save(addingTransaction);
            transaction.commit();
            session.flush();
            session.close();

        } catch (Exception e) {
            e.printStackTrace();
        }



    }

    void addTransactionItems() {



        for (int k = 0; k < transactionItems.size(); k++) {
            try {

                Session session = sessionFactory.openSession();
                Transaction transaction = session.beginTransaction();

                String SQL_QUERY = "insert into transaction_item values (" + Integer.parseInt(this.transactionNumber.getText()) + "," + Integer.parseInt(transactionItems.get(k)[0]) + "," + Integer.parseInt(transactionItems.get(k)[2]) + "," + Float.parseFloat(transactionItems.get(k)[3]) + ")";

                SQLQuery query = session.createSQLQuery(SQL_QUERY);
                // oneStopShop.Beans.Transaction transact = (oneStopShop.Beans.Transaction) query.uniqueResult();
                query.executeUpdate();

                //session.save(addingTransactionItems);
                transaction.commit();
                session.flush();
                session.close();

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    void updateCreditBalance() {

        double totalAmount = Double.parseDouble(this.transactionTotalCost.getText());
        double creditBalance = Double.parseDouble(this.transactionCreditBalance.getText());
        float updateCreditBalance;

        if (creditBalance > totalAmount) {
            updateCreditBalance = (float) (creditBalance - totalAmount);
        } else {
            updateCreditBalance = 0;
        }

        try {

            Session session = sessionFactory.openSession();
            Transaction transaction = session.beginTransaction();

            String SQL_QUERY = "update account set credit_balance =" + Float.toString(updateCreditBalance) + " where customer_number =" + Integer.parseInt(this.transactionCustomerNumber.getText());

            SQLQuery query = session.createSQLQuery(SQL_QUERY);
            // oneStopShop.Beans.Transaction transact = (oneStopShop.Beans.Transaction) query.uniqueResult();
            query.executeUpdate();





            //session.save(addingTransactionItems);
            transaction.commit();
            session.flush();
            session.close();

        } catch (Exception e) {
            e.printStackTrace();
        }


    }

    void deleteTransactedOrder() {

       String deleteOrderNumber = this.transactionOrderNumber.getText();

        try {

            Session session = sessionFactory.openSession();
            Transaction transaction = session.beginTransaction();

            String SQL_QUERY = "delete from customer_order where order_number =" + deleteOrderNumber;

            SQLQuery query = session.createSQLQuery(SQL_QUERY);
            // oneStopShop.Beans.Transaction transact = (oneStopShop.Beans.Transaction) query.uniqueResult();
            query.executeUpdate();

            //session.save(addingTransactionItems);
            transaction.commit();
            session.flush();
            session.close();

        } catch (Exception e) {
            e.printStackTrace();
        }



    }

//    void deleteTransactionOrderItems() {
//
//        String deleteOrderNumber = this.transactionOrderNumber.getText();
//
//
//
//        try {
//
//            Session session = sessionFactory.openSession();
//            Transaction transaction = session.beginTransaction();
//
//            String SQL_QUERY = "delete from order_item where order_number =" + deleteOrderNumber;
//
//            SQLQuery query = session.createSQLQuery(SQL_QUERY);
//            // oneStopShop.Beans.Transaction transact = (oneStopShop.Beans.Transaction) query.uniqueResult();
//            query.executeUpdate();
//
//            //session.save(addingTransactionItems);
//            transaction.commit();
//            session.flush();
//            session.close();
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//
//        this.deleteTransactedOrder(deleteOrderNumber);
//
//    }

    void updateAvailableQuantity() {

        for (int k = 0; k < transactionItems.size(); k++) {
            try {

                Session session1 = sessionFactory.openSession();
                Transaction transaction1 = session1.beginTransaction();

                Item currentUpdatingItem = (Item) session1.createCriteria(Item.class).add(Restrictions.eq("itemNumber", Integer.parseInt(transactionItems.get(k)[0]))).uniqueResult();


                //session.save(addingTransactionItems);
                transaction1.commit();
                session1.flush();
                session1.close();


                Session session2 = sessionFactory.openSession();
                Transaction transaction2 = session2.beginTransaction();

                String itemQuantityAfterTransaction = Integer.toString(currentUpdatingItem.getAvailableQuantity() - Integer.parseInt(transactionItems.get(k)[2]));

                String SQL_QUERY = "update item set available_quantity =" + itemQuantityAfterTransaction + " where item_number =" + transactionItems.get(k)[0];

                SQLQuery query = session2.createSQLQuery(SQL_QUERY);
                // oneStopShop.Beans.Transaction transact = (oneStopShop.Beans.Transaction) query.uniqueResult();
                query.executeUpdate();



                //session.save(addingTransactionItems);
                transaction2.commit();
                session2.flush();
                session2.close();

            } catch (Exception e) {
                e.printStackTrace();
            }
        }


    }

    private void transactionOrderedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transactionOrderedActionPerformed

        transactionItems = new ArrayList<String[]>();
        this.transactionItemTable.setModel(new TableModelTransactionItem(transactionItems));

        this.transactionQuantity.setEnabled(false);
        this.jLabel7.setEnabled(false);
        this.item.setEnabled(false);
        this.transactionItemNumber.setEnabled(false);
        this.transactionItemOk.setEnabled(false);
        this.transactionItemDelete.setEnabled(false);


        this.transactionOrderNumber.setEnabled(true);
        this.jLabel8.setEnabled(true);
        this.transactionOrderAdvanceAmount.setEnabled(true);
        this.jLabel39.setEnabled(true);
        this.transactionOrderOk.setEnabled(true);
        this.jLabel38.setEnabled(true);

    // TODO add your handling code here:
}//GEN-LAST:event_transactionOrderedActionPerformed

    private void transactionOrderOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transactionOrderOkActionPerformed

        this.getOrder();

        this.transactionItemTable.setModel(new TableModelTransactionItem(transactionItems));
    // TODO add your handling code here:
}//GEN-LAST:event_transactionOrderOkActionPerformed

    void getOrder() {
        int transactionOderNum = Integer.parseInt(this.transactionOrderNumber.getText());

        try {
            Session session1 = sessionFactory.openSession();
            Transaction transaction1 = session1.beginTransaction();

            CustomerOrder cusOrder = (CustomerOrder) session1.createCriteria(CustomerOrder.class).add(Restrictions.eq("orderNumber", transactionOderNum)).uniqueResult();

            transaction1.commit();


            this.transactionOrderAdvanceAmount.setText(Double.toString(cusOrder.getAdvanceAmount()));
            this.transactionTotalCost.setText(Double.toString(cusOrder.getOrderCost()));
            this.transactionCustomerNumber.setText(Integer.toString(cusOrder.getCustomerNumber()));

            session1.flush();
            session1.close();


            Session session2 = sessionFactory.openSession();
            Transaction transaction2 = session2.beginTransaction();

            String SQL_QUERY = "select * from order_item where order_number =" + Integer.toString(transactionOderNum);

            SQLQuery query = session2.createSQLQuery(SQL_QUERY);
            // oneStopShop.Beans.Transaction transact = (oneStopShop.Beans.Transaction) query.uniqueResult();
            List orderItem = query.list();

            transaction2.commit();
            session2.flush();
            session2.close();


            for (int j = 0; j < orderItem.size(); j++) {

                Session session3 = sessionFactory.openSession();
                Transaction transaction3 = session3.beginTransaction();


                Object[] currentItemObject = (Object[]) orderItem.get(j);

                int currentItemNumber = (Integer) currentItemObject[1];
                int currentQuantity = (Integer) currentItemObject[2];
                double currentAmount = (Float) currentItemObject[3];

                Item orderItemN = (Item) session3.createCriteria(Item.class).add(Restrictions.eq("itemNumber", currentItemNumber)).uniqueResult();

                transaction3.commit();
                session3.flush();
                session3.close();

                String[] row = {Integer.toString(currentItemNumber), orderItemN.getItemDescription(), Integer.toString(currentQuantity), Double.toString(currentAmount)};

                transactionItems.add(row);

            }



        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton7ActionPerformed

    private void list1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_list1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_list1ActionPerformed

    private void transactionItemOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transactionItemOkActionPerformed


        this.transactionItem();

        this.transactionItemTable.setModel(new TableModelTransactionItem(transactionItems));
        this.totalCostCalculation();
    // TODO add your handling code here:
    }//GEN-LAST:event_transactionItemOkActionPerformed

    void totalCostCalculation() {

        String[] transactionItem;

        double totalCost = 0;

        for (int i = 0; i < transactionItems.size(); i++) {

            transactionItem = transactionItems.get(i);

            String itemCostAmount = transactionItem[3];

            totalCost += Double.parseDouble(itemCostAmount);


        }

        this.transactionTotalCost.setText(Double.toString(totalCost));

    }

    void transactionItem() {
        int itemNumber = Integer.parseInt(this.transactionItemNumber.getText());
        int quantity = Integer.parseInt(this.transactionQuantity.getText());

        try {
            Session session = sessionFactory.openSession();
            Transaction transaction = session.beginTransaction();

            Item tranceItem = (Item) session.createCriteria(Item.class).add(Restrictions.eq("itemNumber", itemNumber)).uniqueResult();

            transaction.commit();
            session.flush();
            session.close();

            String amount = Double.toString(tranceItem.getItemPrice() * quantity);

            String[] row = {this.transactionItemNumber.getText(), tranceItem.getItemDescription(), this.transactionQuantity.getText(), amount};

            transactionItems.add(row);

            this.transactionItemNumber.setText(null);
            this.transactionQuantity.setText(null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void transactionQuantityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transactionQuantityActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_transactionQuantityActionPerformed

    private void transactionNormalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transactionNormalActionPerformed

        transactionItems = new ArrayList<String[]>();
        this.transactionItemTable.setModel(new TableModelTransactionItem(transactionItems));
        this.transactionOrderNumber.setEnabled(false);
        this.jLabel8.setEnabled(false);
        this.transactionOrderAdvanceAmount.setEnabled(false);
        this.jLabel39.setEnabled(false);
        this.transactionOrderOk.setEnabled(false);
        this.jLabel38.setEnabled(false);

        this.transactionQuantity.setEnabled(true);
        this.jLabel7.setEnabled(true);
        this.item.setEnabled(true);
        this.transactionItemNumber.setEnabled(true);
        this.transactionItemOk.setEnabled(true);
        this.transactionItemDelete.setEnabled(true);


    // TODO add your handling code here:
    }//GEN-LAST:event_transactionNormalActionPerformed

    private void transactionItemDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transactionItemDeleteActionPerformed


        this.deleteTransactionItem();

        this.transactionItemTable.setModel(new TableModelTransactionItem(transactionItems));
        this.totalCostCalculation();
    // TODO add your handling code here:
    }//GEN-LAST:event_transactionItemDeleteActionPerformed

    private void transactionCreditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transactionCreditActionPerformed

        if (this.transactionCustomerNumber.getText() != null) {
            this.jLabel42.setEnabled(true);
            this.jLabel40.setEnabled(true);
            this.transactionCreditBalance.setEnabled(true);

            this.retrieveCreditBalance();

        }

    // TODO add your handling code here:
    }//GEN-LAST:event_transactionCreditActionPerformed

    void retrieveCreditBalance() {
        int transactionCustomerNum = Integer.parseInt(this.transactionCustomerNumber.getText());

        try {
            Session session = sessionFactory.openSession();
            Transaction transaction = session.beginTransaction();

            Account customerCreditBalance = (Account) session.createCriteria(Account.class).add(Restrictions.eq("customerNumber", transactionCustomerNum)).uniqueResult();

            transaction.commit();
            session.flush();
            session.close();

            this.transactionCreditBalance.setText(Double.toString(customerCreditBalance.getCreditBalance()));


        } catch (Exception e) {
            e.printStackTrace();
        }




    }

    private void transactionCashActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transactionCashActionPerformed

        this.transactionCreditBalance.setText(null);
        this.jLabel42.setEnabled(false);
        this.jLabel40.setEnabled(false);
        this.transactionCreditBalance.setEnabled(false);
    // TODO add your handling code here:
    }//GEN-LAST:event_transactionCashActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        setTransactionNumber();
        this.transactionCustomerNumber.setText(null);
        this.transactionDateTime.setText((new Date()).toString());
        transactionItems = new ArrayList<String[]>();
        this.transactionItemTable.setModel(new TableModelTransactionItem(transactionItems));
        this.transactionNormal.setSelected(true);
        this.transactionNormalActionPerformed(evt);

        this.transactionItemNumber.setText(null);
        this.transactionQuantity.setText(null);
        this.transactionOrderNumber.setText(null);
        this.transactionOrderAdvanceAmount.setText(null);
        this.transactionTotalCost.setText(null);
        this.transactionCreditBalance.setText(null);

        this.transactionCash.setSelected(true);
        this.transactionCashActionPerformed(evt);
    // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void transactionLogSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transactionLogSearchActionPerformed

        this.searchTransactionLog();


    // TODO add your handling code here:
    }//GEN-LAST:event_transactionLogSearchActionPerformed

    private void transactionLogRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transactionLogRefreshActionPerformed


        this.transactionLogCustomerNumber.setText(null);
        this.loadTransactionLog();
        transactionLogItemTableRefresh();

    // TODO add your handling code here:
    }//GEN-LAST:event_transactionLogRefreshActionPerformed

    private void orderLogRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_orderLogRefreshActionPerformed

         this.orderLogCustomerNumber.setText(null);
        this.loadOrderLog();
        orderLogItemTableRefresh();

        // TODO add your handling code here:
}//GEN-LAST:event_orderLogRefreshActionPerformed


      void orderLogItemTableRefresh(){
        orderLogItems = new ArrayList<String[]>();
       this.orderLogsItems.setModel(new TableModelTransactionItem(orderLogItems));


    }

    private void orderLogSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_orderLogSearchActionPerformed

        
           this.searchOrderLog();
        // TODO add your handling code here:
    }//GEN-LAST:event_orderLogSearchActionPerformed

    private void customerAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customerAddActionPerformed
        String msg = this.validateForm();
        if (msg == null) {
            this.addCustomer();
        } else {
            JOptionPane.showMessageDialog(this, msg, "Invalid input", JOptionPane.ERROR_MESSAGE);

        }
    }//GEN-LAST:event_customerAddActionPerformed

    private void customerEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customerEditActionPerformed

        String msg = this.validateForm();
        if (msg == null) {
            this.editCustomer();
        } else {
            JOptionPane.showMessageDialog(this, msg, "Invalid input", JOptionPane.ERROR_MESSAGE);

        }

    }//GEN-LAST:event_customerEditActionPerformed

    private void customerDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customerDeleteActionPerformed
        int rowIndex = customerTable.getSelectedRow();                                 //author-dinesh
        String customerNumber = (String) customerTable.getValueAt(rowIndex, 0);
        Customer cus = this.getCustomer(Integer.parseInt(customerNumber));
        int choise = JOptionPane.showConfirmDialog(this, "Customer " + cus.getName() + " will be deleted,do you want to continue?", "Customer Deletion", JOptionPane.YES_NO_OPTION);
        if (choise == JOptionPane.YES_OPTION) {
            Session session = null;

            try {
                session = sessionFactory.openSession();
                Object loadCus = session.load(Customer.class, Integer.parseInt(customerNumber));
                Transaction transaction = session.beginTransaction();
                session.delete(loadCus);
                transaction.commit();
                JOptionPane.showMessageDialog(this, "Customer deletd successfully!", "Deleted!", JOptionPane.INFORMATION_MESSAGE);
                //this.loadDataToTable();
                this.refreshCustomerWindow();
                this.modifyAccountWindow();
            } catch (Exception e) {
                System.out.println("Exception in deleting customer");
            } finally {
                session.close();
            }

        }
    }//GEN-LAST:event_customerDeleteActionPerformed

    private void customerTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_customerTableMouseClicked
        System.out.println(">>>>>mouse clisked" + customerTable.getSelectedRow());  //author-dinesh
        customerEdit.setEnabled(true);
        customerDelete.setEnabled(true);
        customerAdd.setEnabled(false);
        this.customerCustomerNumber.setEnabled(false);
        this.customerCustomerType.setEnabled(false);
        int rowIndex = customerTable.getSelectedRow();//author-dinesh
        String customerNumber = (String) customerTable.getValueAt(rowIndex, 0);
        Customer cus = this.getCustomer(Integer.parseInt(customerNumber));
        customerCustomerType.setSelectedIndex(cus.getCustomerType() - 1);

        this.customerCustomerNumber.setText(Integer.toString(cus.getCustomerNumber()));
        this.customerCustomerName.setText(cus.getName());
        this.customerCustomerAddress.setText(cus.getAddress());
        this.customerContactNumber.setText(Integer.toString(cus.getContactNumber()));

        if (cus.getCustomerType() == 2 || cus.getCustomerType() == 4 || cus.getCustomerType() == 3) {
            Account acc = this.getAccount(Integer.parseInt(customerNumber));
            this.customerCustomerCreditLimit.setText(Float.toString(acc.getCreditLimit()));
            this.customerCustomerCreditBalance.setText(Float.toString(acc.getCreditBalance()));
            this.customerCustomerAcountID.setText(Integer.toString(acc.getAccountId()));

            if (cus.getCustomerType() == 3) {
                LargeOrderCustomer lCus = this.getLargeOrderCustomer(Integer.parseInt(customerNumber));
                this.customerSalesRepID.setText(Integer.toString(lCus.getSalesRepId()));
                this.brn.setText(Integer.toString(lCus.getBrn()));
            }

        }

    }//GEN-LAST:event_customerTableMouseClicked

    private void customerTableComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_customerTableComponentShown
        // TODO add your handling code here:
}//GEN-LAST:event_customerTableComponentShown

    private void customerCustomerNumberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customerCustomerNumberActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_customerCustomerNumberActionPerformed

    private void customerCustomerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customerCustomerTypeActionPerformed

        this.customerTypeChange();     //author-dinesh
}//GEN-LAST:event_customerCustomerTypeActionPerformed

    private void customerCustomerCreditLimitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customerCustomerCreditLimitActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_customerCustomerCreditLimitActionPerformed

    private void customerSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customerSearchActionPerformed
        /**/
        try {
            int customerID = Integer.parseInt(this.customerCustomerIDSearch.getText().trim());

            try {
                Customer cus = this.getCustomer(customerID);
                List<Customer> list = new ArrayList<Customer>();
                list.add(cus);
                this.customerTable.setModel(new CustomerTableModel(list));
            } catch (Exception e) {
                JOptionPane.showMessageDialog(this, "Can't find customer with given customer number!", "Error", JOptionPane.ERROR_MESSAGE);

            }


        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Customer number should be inserted!", "Invalid input", JOptionPane.ERROR_MESSAGE);

        }
    }//GEN-LAST:event_customerSearchActionPerformed

    private void customerRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customerRefreshActionPerformed
        this.refreshCustomerWindow();//author-dinesh
}//GEN-LAST:event_customerRefreshActionPerformed

    private void accountTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_accountTableMouseClicked

        this.accountPaymentAmmountLable.setEnabled(true);        //author-dinesh
        this.accountPaymentAmmount.setEnabled(true);
        this.accountAdd.setEnabled(true);
        this.accountRefresh.setEnabled(true);
}//GEN-LAST:event_accountTableMouseClicked

    private void accountAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_accountAddActionPerformed
        try {
            float payment = Float.parseFloat(this.accountPaymentAmmount.getText().trim());

            int rowIndex = accountTable.getSelectedRow();                           //author-dinesh
            String customerID = (String) accountTable.getValueAt(rowIndex, 1);
            Account acc = this.getAccount(Integer.parseInt(customerID));

            float usedAmmount = acc.getCreditLimit() - acc.getCreditBalance();
            Session session = null;
            if (payment <= usedAmmount && payment > 0) {
                usedAmmount = usedAmmount - payment;
                try {

                    acc.setCreditBalance(acc.getCreditLimit() - usedAmmount);
                    session = sessionFactory.openSession();
                    Transaction transaction = session.beginTransaction();

                    session.update(acc);
                    transaction.commit();
                    this.refreshAccountWindow();


                } catch (Exception e) {

                    JOptionPane.showMessageDialog(this, "Error in adding payment!", "Error", JOptionPane.ERROR_MESSAGE);

                } finally {
                    session.close();
                }
            } else {
                JOptionPane.showMessageDialog(this, "Invalid payment amount!", "Invalid payment", JOptionPane.ERROR_MESSAGE);

            }

        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "Invalid input!", "Invalid input", JOptionPane.ERROR_MESSAGE);

        }



    }//GEN-LAST:event_accountAddActionPerformed

    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed
        //author-dinesh
        try {
            int accountID = Integer.parseInt(this.accountSearchID.getText().trim());

            try {
                Account acc = this.getAccountByAccountID(accountID);
                List<Account> list = new ArrayList<Account>();
                list.add(acc);
                this.accountTable.setModel(new AccountTableModel(list));
                this.accountPaymentAmmountLable.setEnabled(false);        //author-dinesh
                this.accountPaymentAmmount.setEnabled(false);
                this.accountAdd.setEnabled(false);
                this.accountRefresh.setEnabled(true);

            } catch (Exception e) {
                JOptionPane.showMessageDialog(this, "Can't find account with given account ID!", "Error", JOptionPane.ERROR_MESSAGE);

            }


        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Account ID should be inserted!", "Invalid input", JOptionPane.ERROR_MESSAGE);

        }
}//GEN-LAST:event_jButton18ActionPerformed

    private void accountRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_accountRefreshActionPerformed
        this.refreshAccountWindow();         //author-dinesh
}//GEN-LAST:event_accountRefreshActionPerformed

    private void transactionLogTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_transactionLogTableMouseClicked

        this.retrieveTransactionLogItems();
        // TODO add your handling code here:
    }//GEN-LAST:event_transactionLogTableMouseClicked

    private void orderLogTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_orderLogTableMouseClicked

        retrieveOrderLogItems();
        // TODO add your handling code here:
    }//GEN-LAST:event_orderLogTableMouseClicked



     void retrieveOrderLogItems() {

        int selectedRow = this.orderLogTable.getSelectedRow();

        String selectedOrderNumber = (String) this.orderLogTable.getValueAt(selectedRow, 0);

        orderLogItems = new ArrayList<String[]>();

        try {

            Session session1 = sessionFactory.openSession();
            Transaction transaction1 = session1.beginTransaction();

            String SQL_QUERY = "select * from order_item where order_number =" + selectedOrderNumber;

            SQLQuery query = session1.createSQLQuery(SQL_QUERY);
            //Object df = query.uniqueResult();
            List<Object[]> ordLogItem = (List<Object[]>) query.list();

            //session.save(addingTransactionItems);
            transaction1.commit();
            session1.flush();
            session1.close();




            for (int i = 0; i < ordLogItem.size(); i++) {

                Session session2 = sessionFactory.openSession();
                Transaction transaction2 = session2.beginTransaction();

                Item ordItem = (Item) session2.createCriteria(Item.class).add(Restrictions.eq("itemNumber", ordLogItem.get(i)[1] )).uniqueResult();

                transaction2.commit();
                session2.flush();
                session2.close();

               String[] orderLogItemRow = {Integer.toString((Integer)ordLogItem.get(i)[1]),ordItem.getItemDescription(),Integer.toString((Integer)ordLogItem.get(i)[2]),Float.toString((Float)ordLogItem.get(i)[3])};
              orderLogItems.add(orderLogItemRow);
            }


        } catch (Exception e) {
            e.printStackTrace();
        }



        this.orderLogsItems.setModel(new TableModelTransactionItem(orderLogItems));


    }


        void searchOrderLog() {
        // int transacLogCustomerNumber = Integer.parseInt(this.transactionLogCustomerNumber.getText());


        ArrayList<String[]> orderLogArrayList = orderLogs;

        orderLogs = new ArrayList<String[]>();

        for (int i = 0; i < orderLogArrayList.size(); i++) {

            String ordLogCusNum = orderLogArrayList.get(i)[3];

            if (ordLogCusNum.equals(this.orderLogCustomerNumber.getText())) {
                orderLogs.add(orderLogArrayList.get(i));
            }

        }

        this.orderLogTable.setModel(new TableModelOrderLog(orderLogs));

    }


    void retrieveTransactionLogItems() {

        int selectedRow = this.transactionLogTable.getSelectedRow();

        String selectedTransactionNumber = (String) this.transactionLogTable.getValueAt(selectedRow, 0);

        transactionLogItems = new ArrayList<String[]>();

        try {

            Session session1 = sessionFactory.openSession();
            Transaction transaction1 = session1.beginTransaction();

            String SQL_QUERY = "select * from transaction_item where trn =" + selectedTransactionNumber;

            SQLQuery query = session1.createSQLQuery(SQL_QUERY);
            //Object df = query.uniqueResult();
            List<Object[]> transacLogItem = (List<Object[]>) query.list();

            //session.save(addingTransactionItems);
            transaction1.commit();
            session1.flush();
            session1.close();




            for (int i = 0; i < transacLogItem.size(); i++) {

                Session session2 = sessionFactory.openSession();
                Transaction transaction2 = session2.beginTransaction();

                Item tranceItem = (Item) session2.createCriteria(Item.class).add(Restrictions.eq("itemNumber", transacLogItem.get(i)[1] )).uniqueResult();

                transaction2.commit();
                session2.flush();
                session2.close();

               String[] transactionLogItemRow = {Integer.toString((Integer)transacLogItem.get(i)[1]),tranceItem.getItemDescription(),Integer.toString((Integer)transacLogItem.get(i)[2]),Float.toString((Float)transacLogItem.get(i)[3])};
              transactionLogItems.add(transactionLogItemRow);
            }


        } catch (Exception e) {
            e.printStackTrace();
        }



        this.transactionLogsItems.setModel(new TableModelTransactionItem(transactionLogItems));





    }

    void searchTransactionLog() {
        // int transacLogCustomerNumber = Integer.parseInt(this.transactionLogCustomerNumber.getText());


        ArrayList<String[]> transactionLogArrayList = transactionLogs;

        transactionLogs = new ArrayList<String[]>();

        for (int i = 0; i < transactionLogArrayList.size(); i++) {

            String transacLogCusNum = transactionLogArrayList.get(i)[1];

            if (transacLogCusNum.equals(this.transactionLogCustomerNumber.getText())) {
                transactionLogs.add(transactionLogArrayList.get(i));
            }

        }

        this.transactionLogTable.setModel(new TableModelTransactionLog(transactionLogs));

    }

    void deleteTransactionItem() {

        int deleteRow = this.transactionItemTable.getSelectedRow();

        String selectedItemNumber = (String) this.transactionItemTable.getValueAt(deleteRow, 0);
        String[] selectedItem;

        for (int i = 0; i < transactionItems.size(); i++) {

            selectedItem = transactionItems.get(i);

            if (selectedItem[0].equals(selectedItemNumber)) {

                transactionItems.remove(i);
            }

        }

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainForm().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel accountAccountIDLable;
    private javax.swing.JButton accountAdd;
    private javax.swing.JPanel accountPanel;
    private javax.swing.JTabbedPane accountPanel2;
    private javax.swing.JTextField accountPaymentAmmount;
    private javax.swing.JLabel accountPaymentAmmountLable;
    private javax.swing.JButton accountRefresh;
    private javax.swing.JTextField accountSearchID;
    private javax.swing.JTable accountTable;
    private javax.swing.JTextField brn;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JLabel customerAccountIDLable;
    private javax.swing.JButton customerAdd;
    private javax.swing.JLabel customerAddressLable;
    private javax.swing.JLabel customerBRN;
    private javax.swing.JTextField customerContactNumber;
    private javax.swing.JLabel customerContactNumberLable;
    private javax.swing.JLabel customerCreditBalanceLable;
    private javax.swing.JLabel customerCreditLimitLable;
    private javax.swing.JLabel customerCustomerAcountID;
    private javax.swing.JTextField customerCustomerAddress;
    private javax.swing.JLabel customerCustomerCreditBalance;
    private javax.swing.JTextField customerCustomerCreditLimit;
    private javax.swing.JTextField customerCustomerIDSearch;
    private javax.swing.JLabel customerCustomerIDSearchLable;
    private javax.swing.JTextField customerCustomerName;
    private javax.swing.JTextField customerCustomerNumber;
    private javax.swing.JComboBox customerCustomerType;
    private javax.swing.JLabel customerCustomerTypeLable;
    private javax.swing.JLabel customerCutomerNumberLable;
    private javax.swing.JButton customerDelete;
    private javax.swing.JButton customerEdit;
    private javax.swing.JLabel customerNameLable;
    private javax.swing.JPanel customerPanel;
    private javax.swing.JButton customerRefresh;
    private javax.swing.JTextField customerSalesRepID;
    private javax.swing.JLabel customerSalesRepIDLable;
    private javax.swing.JButton customerSearch;
    private javax.swing.JTable customerTable;
    private javax.swing.JLabel item;
    private javax.swing.JLabel item1;
    private javax.swing.JLabel item2;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable4;
    private javax.swing.JTable jTable5;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField11;
    private javax.swing.JTextField jTextField12;
    private javax.swing.JTextField jTextField13;
    private javax.swing.JTextField jTextField14;
    private javax.swing.JTextField jTextField15;
    private javax.swing.JTextField jTextField16;
    private javax.swing.JTextField jTextField22;
    private javax.swing.JTextField jTextField23;
    private javax.swing.JTextField jTextField24;
    private javax.swing.JTextField jTextField25;
    private javax.swing.JTextField jTextField26;
    private javax.swing.JTextField jTextField27;
    private javax.swing.JTextField jTextField28;
    private java.awt.List list1;
    private java.awt.List list2;
    private javax.swing.JTextField orderLogCustomerNumber;
    private javax.swing.JButton orderLogRefresh;
    private javax.swing.JButton orderLogSearch;
    private javax.swing.JTable orderLogTable;
    private javax.swing.JTable orderLogsItems;
    private javax.swing.JPanel orderPanel;
    private javax.swing.JButton transactionAdd;
    private javax.swing.JRadioButton transactionCash;
    private javax.swing.JRadioButton transactionCredit;
    private javax.swing.JLabel transactionCreditBalance;
    private javax.swing.JTextField transactionCustomerNumber;
    private javax.swing.JLabel transactionDateTime;
    private javax.swing.JButton transactionItemDelete;
    private javax.swing.JTextField transactionItemNumber;
    private javax.swing.JButton transactionItemOk;
    private javax.swing.JTable transactionItemTable;
    private javax.swing.JTextField transactionLogCustomerNumber;
    private javax.swing.JButton transactionLogRefresh;
    private javax.swing.JButton transactionLogSearch;
    private javax.swing.JTable transactionLogTable;
    private javax.swing.JTable transactionLogsItems;
    private javax.swing.JRadioButton transactionNormal;
    private javax.swing.JLabel transactionNumber;
    private javax.swing.JLabel transactionOrderAdvanceAmount;
    private javax.swing.JTextField transactionOrderNumber;
    private javax.swing.JButton transactionOrderOk;
    private javax.swing.JRadioButton transactionOrdered;
    private javax.swing.JPanel transactionPanel;
    private javax.swing.JTextField transactionQuantity;
    private javax.swing.JLabel transactionTotalCost;
    // End of variables declaration//GEN-END:variables
}
